<script>
	export default {
		onLaunch: function() {
			// #ifdef APP-PLUS
			const domModule = uni.requireNativePlugin('dom')
			domModule.addRule('fontFace', {
				'fontFamily': "graceuiiconfont",
				'src': "url('https://at.alicdn.com/t/c/font_823462_whtuj4ktcl.ttf?t=1703075468532')"
			});
			console.log("字体加载成功");
			console.log(uni.getStorageSync('ttyhtoken'));
			if(uni.getStorageSync('ttyhtoken')){
				let userInfo = JSON.parse(uni.getStorageSync('ttyhtoken'));
				console.log(userInfo)
				this.ybapi.Backuser_GetData(userInfo.userid,function(data){
					console.log(data.data);
					if(data.data){
						console.log("直接跳转主页");
						uni.switchTab({
							url: "/pages/products/products",
							success: () => {
								setTimeout(() => {
									plus.navigator.closeSplashscreen();
								},2400);
							}
						})					
					} else {
						plus.navigator.closeSplashscreen();
						uni.removeStorageSync('ttyhtoken');
						uni.showToast({
							title: "该账户已注销",
							icon: "none",
							position: "bottom"
						})
					}
				},function(e){
					console.log(e);
				});
			} else {
				uni.reLaunch({
					url: "/pages/login/login",
					success: () => {
						plus.navigator.closeSplashscreen();
					}
				})
			}
			// #endif
			
			// #ifdef MP-WEIXIN
			wx.onNeedPrivacyAuthorization(function(e) {
				console.log(e);
			})
			// #endif
		},
		onShow: function() {},
		onHide: function() {}
	}
</script>

<style lang="scss">
	/* 加载框架核心样式 */
	@import "./Grace6/css/grace.scss";
	/* 加载深色模式适配样式 */
	@import "./Grace6/css/graceDark.scss";
	/* 加载自定义样式 */
	@import "./custom/custom.scss";
	page {
		background: #F8F8F8;
	}
</style>